<?php
namespace App\Common\Cla\Err;

use App\Common as com;

/**
 * 用户的错误说明
 * @author Administrator
 *
 */
class UserText extends com\Cla\ClaBase {

	protected static $code = null;
	
	// ===============================
	//
	//
	// 下面为静态方法
	//
	//
	// ===============================
	
	/**
	 * 初始化"用户的错误说明"
	 * @return bool [true]成功 [false]初始化失败
	 */
	protected static function initVarCode():bool {
		if( self::$code !== null ) return true;
		self::$code = [
			com\Cla\Err\Code::$appPageComParamError => '页面参数错误，请稍后重试',
		];
		return true;
	}
	
	/**
	 * 获取错误码说明
	 * @param int $error_code 错误码
	 * @param array $param 参数数组 <br />
	 * ················· [可空](str)	$param['default_str']	说明：模式的错误说明。['']默认	<br />
	 * ················· [可空/多选_A/必须](unknown_type)	$param['AAAAA']	说明：AAAAA	<br />
	 * @return string 错误说明
	 */
	public static function getText( $error_code, array $param = [] ):string {
		// ...
		$param['default_str'] = $param['default_str'] ?? '';
		//
		self::initVarCode();
		//
		return self::$code[ $error_code ] ?? $param['default_str'];
	}

}